use thiserror::Error;


#[derive(Error, Debug)]
pub enum IWError {
    #[error("unknown iw error")]
    Unknown,

    #[error("iw socket fail")]
    Socket,
}

pub type Result<T=()> = std::result::Result<T, IWError>;


pub fn handle_err(r: i32)->Result<i32>{
    if r < 0{
        return  Err(IWError::Unknown);
    }
    Ok(r)
}

macro_rules! iw_bail {
    ($r:expr) => {
        $crate::err::handle_err($r)?       
    };
}